<template>
	<view class="flow_box">
		<scroll-view scroll-y="true">
      <view class="welfares">
         <template v-for="item in data.list" key="id">
          <view class="welfares-good" @click="tapClick(item)" :name="item.name" :goodsid="item.id">
            <view>
              <image :src="item.picUrl" class="welfares-image" mode="widthFix"/> 
            </view>
            <view class="product-name">
              {{item.name}}
            </view>
            <view class="product-price-wrap">
              <p class="product-price-new">￥{{item.price}}</p>  
              <p class="discount">售卖{{item.sales}}+</p>  
            </view>
            
          </view>
        </template> 
      </view>
  </scroll-view>  
  <view class="weui-loadmore" hidden="{{hidden}}">
    <view class="weui-loading"></view>
    <view class="weui-loadmore__tips">努力加载中</view>
  </view>  
	</view>
</template>
<script setup>
import { ref, reactive, computed, onMounted, onBeforeMount } from 'vue';
import { onShow, onHide, onLoad } from "@dcloudio/uni-app"
import http from '../../../../common/http.js'

const data = reactive({
	list: [{
			picUrl: 'https://via.placeholder.com/200x100.png/ff0000',
			name: '睡裙女夏季冰丝睡衣少女士性感',
		},
		{
			picUrl: 'https://via.placeholder.com/200x200.png/2878ff',
			name: '古驰香水',
		},
		
	]
})
onShow(async () => {
	await http({
		url: `/goods-api/app-api/goods`,
		method: "get"
	}, {}).then(res => {
		data.list = res.data
	})
})
const column = ref(2);

function add() {
	const newArr = [{
		picUrl: 'https://via.placeholder.com/58x100.png/FF7F50',
		name: '我是标题8',
	},
	{
		picUrl: 'https://via.placeholder.com/59x100.png/C0C0C0',
		name: '我是标题9',
	},
	{
		picUrl: 'https://via.placeholder.com/60x100.png/FAEBD7',
		name: '我是标题10',
	}
	]
	data.list = data.list.concat(newArr);
}
const tapClick = (item) => {
	console.log(item);
	uni.navigateTo({
		url: '/pages/goodsDetails/goodsDetails?id='+item.id+"&picUrl="+item.picUrl
	})
}
</script>
<style lang="scss" scoped>
.flow_box {
	padding: 0 32rpx;
}

.item {
	padding-top: 16rpx;

	.title {
		max-height: 72rpx;
		line-height: 28rpx;
	}
}

/**=========福利专场============**/
.welfares{
  display: flex;
  justify-content: left;
  flex-direction: row;
  flex-wrap: wrap;
  margin:10px 5px;
}
.welfares-good{
  /* height: 500rpx;  */
  width: 47%;
  margin:0px auto;
  margin-bottom: 20px;
  position: relative;
  display: inline-block;
  font-size: 24rpx;
  /* border: 1px #eee solid;  */
}
.welfares-image{
  width: 100%;
  display: inline-block;
  border: 1px #eee solid; 
}
.welfares-good .product-name{
  color: #000;
  /* height: 28px; */
  text-align:left;
   margin: 0px 5px; 
   margin-bottom: 5px; 
}
.product-price-wrap{
  height: 40rpx;
}

.product-price-wrap .product-price-new{
  color: #e80080;
  margin-left:5px;
  font-weight:900;
  font-size: 30rpx;
}
.product-price-wrap .product-price-old{
  color: #888;
  text-decoration: line-through;
  padding-left: 2px;
}
.product-price-wrap .discount{
  position: absolute;
  right: 5px;
  background-color: #000;
  color: #fff;
}
/*  加载更多   */
.weui-loading {
  margin: 0 5px;
  width: 20px;
  height: 20px;
  display: inline-block;
  vertical-align: middle;
  -webkit-animation: weuiLoading 1s steps(12, end) infinite;
  animation: weuiLoading 1s steps(12, end) infinite;
  background: transparent url() no-repeat;
  background-size: 100%;
}
.weui-loadmore {
  width: 65%;
  margin: 1.5em auto;
  line-height: 1.6em;
  font-size: 12px;
  text-align: center;
}
.weui-loadmore__tips {
  display: inline-block;
  vertical-align: middle;
  color: #888;
}
</style>
